package com.example.demo;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @Author: LiangJiawen
 * @Create Date Time: 2021/4/20 17:04.
 * @Update Date Time: 
 * @see
 */
@Component
public class TestBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean.getClass() == MyTest.class){
            System.out.println("======【Bean--后置处理器--初始化前】======" + beanName);
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("myTest")){
            System.out.println("======【Bean--后置处理器--初始化后】======" + bean.getClass());
        }
        return bean;
    }
}
